package interfaces;

import java.awt.GridBagLayout;
import java.util.List;

import javax.swing.BorderFactory;
import javax.swing.JCheckBox;
import javax.swing.JPanel;

import model.Days;

import com.google.common.collect.Lists;
/**
 * @author Savva
 *
 */
public class DaysPanel extends JPanel {
	private static final long serialVersionUID = 1L;
	private List<JCheckBox> dayBoxes = Lists.newArrayList();
	private JPanel daysPanel;
	public DaysPanel() {
		daysPanel = new JPanel(new GridBagLayout());
		daysPanel.setBorder(BorderFactory.createTitledBorder("Дни недели"));
		for(Days day : Days.values()) {
			JCheckBox box = new JCheckBox(day.getName());
			dayBoxes.add(box);
			daysPanel.add(box);
		}
		setEnabled(false);
		add(daysPanel);
	}
	
	
	@Override
	public void setEnabled(boolean enabled) {
		for(JCheckBox checkBox: dayBoxes) {
			checkBox.setEnabled(enabled);
		}
		super.setEnabled(enabled);
	}
	
	public List<String> getChecked() {
		List<String> strings = Lists.newArrayList();
		for(JCheckBox checkBox: dayBoxes) {
			if(checkBox.isSelected())
				strings.add(checkBox.getText());
		}
		return strings;
	}
}
